<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./css/login.css">
    <link rel="stylesheet" href="./css/commen.css">
</head>
<body>
    <div class="nav">
        <span>网页聊天室</span>
    </div>
    <div class="login_container">
        <div class="login_dialog">
            <h3>登录</h3>
            <div class="row">
                <span>账号</span>
                <input type="text" id="userName">
            </div>
            <div class="row">
                <span>密码</span>
                <input type="text" id="password">
            </div>
            <button id="login" onclick="login()">登录</button><br>
            <a href="regisry.html">注册</a>
        </div>
    </div>

    <script src="./js/jquery.min.js"></script>
    <script>
        function login() {
            console.log('666')
            let userName = document.querySelector('#userName');
            let password = document.querySelector('#password')
            $.ajax({
                type: 'post',
                url: '/user/login',
                data: {
                    userName: userName.value,
                    password: password.value
                },
                success: function(result) {
                    if (result.data == true) {
                        alert('登陆成功')
                        location.href = 'client.html'
                    }else {
                        alert(result.data);
                    }
                }
            })
        }
    </script>
</body>
</html>